﻿<UserControl x:Class="Ares.GUI.Views.ProjectView"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
             xmlns:Controls="clr-namespace:MahApps.Metro.Controls;assembly=MahApps.Metro"
             xmlns:fluid="clr-namespace:FluidKit.Controls;assembly=FluidKit"
             xmlns:local="clr-namespace:Ares.GUI.Views.SubViews"
             mc:Ignorable="d" 
             d:DesignHeight="300" d:DesignWidth="300">
    <UserControl.Resources>
        <local:WidthConverter x:Key="WidthConverter" />
    </UserControl.Resources>
    <Grid Margin="5,0,5,0">
        <Grid.RowDefinitions>
            <RowDefinition Height="*" />
            <RowDefinition Height="auto" />
        </Grid.RowDefinitions>
        <ListBox Grid.Row="0"
                 VerticalContentAlignment="Top"
                 ScrollViewer.HorizontalScrollBarVisibility="Disabled"
                 BorderThickness="0"
                 Height="auto"
                 ItemsSource="{Binding BackupProjects}">
            <ListBox.ItemsPanel>
                <ItemsPanelTemplate>
                    <WrapPanel />
                </ItemsPanelTemplate>
            </ListBox.ItemsPanel>
            <ListBox.ItemTemplate>
                <!-- The Datatemplate -->
                <DataTemplate DataType="ListBoxItem">
                    <!-- grün CC48cb00 -->
                    <!-- rot CCcb0000 -->
                    <!-- orange CCff9829-->
                    <Border BorderThickness="2" BorderBrush="{Binding OperationColor}" >
                        <Border.BitmapEffect>                     
                                <DropShadowBitmapEffect Color="#ccc" Direction="-45"
                    ShadowDepth="3" Softness=".2" />
                        </Border.BitmapEffect>
                        <StackPanel Width="200" Background="White">
                            <TextBlock Padding="2" Background="{Binding OperationColor}" Foreground="White" Grid.Column="0" FontSize="18" Text="{Binding Project.Name, Mode=TwoWay}" TextTrimming="CharacterEllipsis" TextWrapping="NoWrap" ></TextBlock>
                            <TextBlock Margin ="3" Foreground="#CCC" Text="{Binding LastBackup}" />
                            <StackPanel Visibility="{Binding ControlsVisible}" >
                                <WrapPanel>
                                    <Button Margin="3" Command="{Binding BackupCommand}" Content="Start!" />
                                    <Button Margin="3" Command="{Binding EditCommand}" Content="Edit" />
                                    <Button Margin="3" Command="{Binding DeleteCommand}" Content="Delete" />                           
                                </WrapPanel>
                                <Button Margin="5" Command="{Binding RevertCommand}" Content="Revert" />
                            </StackPanel>
                            <StackPanel Visibility="{Binding ProgressVisible}">
                                <Label Content="{Binding Progress.StatusMessage}" />
                                <ProgressBar IsIndeterminate="False" Value="{Binding Progress.Progress}" Maximum="{Binding Progress.ProgressMax}" />
                            </StackPanel>
                        </StackPanel>
                    </Border>
                </DataTemplate>
            </ListBox.ItemTemplate>
            <ListBox.ItemContainerStyle>
                <Style TargetType="{x:Type ListBoxItem}">
                    <Setter Property="Background" Value="Transparent" />
                    <Setter Property="Margin" Value="5" />
                    <Setter Property="Padding" Value="0" />
                    <Style.Resources>
                        <SolidColorBrush x:Key="{x:Static SystemColors.HighlightBrushKey}" Color="Transparent"/>
                        <SolidColorBrush x:Key="{x:Static SystemColors.ControlBrushKey}" Color="Transparent"/>
                    </Style.Resources>
                </Style>
            </ListBox.ItemContainerStyle>
        </ListBox>
        <WrapPanel Grid.Row="1">
            <Button Margin="5" Command="{Binding OpenProjectCommand}" >Open Project...</Button>
            <Button Margin="5" Command="{Binding NewProjectCommand}" >Create new Project</Button>
        </WrapPanel>
    </Grid>
</UserControl>
